package cn.qyd.concurrentcollection;

import cn.qyd.StackOutMemoryDemo;

import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.TimeUnit;

/**
 * @author 邱运铎
 * @date 2024-03-22 22:19
 */
public class LinkedTransferQueueDemo {
    public static void main(String[] args) throws InterruptedException {
        LinkedTransferQueue<String> queue = new LinkedTransferQueue();

        new Thread(() -> {
            try {
                System.out.println("消费正正在等待消费。。。");
                String take = queue.take();
                System.out.println("消费者成功消费数据： " + take);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        TimeUnit.SECONDS.sleep(1);

        System.out.println("生产者生产数据了： Hello World!!!/或者说在传输数据");
        queue.put("Hello World!!!");
        System.out.println("生产者已转移元素");

    }
}
